<?php
/**
 * 执行论坛版块分类相关操作
 * [ranknow bbs!] (C)2009-2015 ranknow.cn.
 *
 * @author liwei
 * @This is NOT a freeware, use is subject to license terms
 * @rcsfile $RCSfile: do_category.php,v $
 * @revision $Revision: 0.1 $
 * @date $Date: 2009/12/30 09:40:17 $
 */
require_once '../../config.inc.php';
include BBS_MDL_PATH . 'mdl_forum.php';
dbConnect();
$action = $_GET['action']?$_GET['action']:'';
if ( $action == 'add' ) {
    extract( $_POST['category'], EXTR_PREFIX_SAME, "wddx" );
    $data = array( 'name' => $name, 'description' => $description );
    $ref = add_forum( $data );
    if ( $ref ) {
        set_flash( 'sysinfo', '添加版块成功!' );
    } else {
        set_flash( 'sysinfo', '添加版块失败!' );
    }
    header( 'Location: ' . BBS_WEB_ROOT . 'admin/index.php?action=manage_categories' ) ;
} elseif ( $action == 'delete' ) {
    $id = $_GET['id']?$_GET['id']:'0';
    $ref = delete_forum_by_id( $id );
    if ( $ref ) {
        set_flash( 'sysinfo', '删除版块成功!' );
    } else {
        set_flash( 'sysinfo', '删除版块失败!' );
    }
    header( 'Location: ' . BBS_WEB_ROOT . 'admin/index.php?action=manage_categories' ) ;
} elseif ( $action == 'edit' ) {
    extract( $_POST['category'], EXTR_PREFIX_SAME, "wddx" );
    $data = array( 'fid' => $fid, 'name' => $name, 'description' => $description );
    $ref = update_forum( $data );
    if ( $ref ) {
        set_flash( 'sysinfo', '修改版块成功!' );
    } else {
        set_flash( 'sysinfo', '修改版块失败!' );
    }
    header( 'Location: ' . BBS_WEB_ROOT . 'admin/index.php?action=manage_categories' ) ;
}
dbDisconnect();

?>